package net.oschina.app.viewpagerfragment.MyFragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.oschina.app.R;

/**
 * Created by foty on 2017/4/2.
 * ?
 * 资讯和动弹fragment的基类,fragmentde(包含了tabLayout 和 viewpager)的内部的fragment的基类,
 */

public abstract class BaseFragment extends Fragment {
    public Context mContext;
    public ViewPager mViewPager;
    public TabLayout mTabLayout;

    public BaseFragment(Context context){
        mContext  = context;

    }

    public BaseFragment() {

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
       // View view = getFragmentView(container);
        View view = View.inflate(getContext(), R.layout.base_fragment,null);
        mViewPager = (ViewPager) view.findViewById(R.id.base_vp);
        mTabLayout = (TabLayout) view.findViewById(R.id.base_tab);

        mTabLayout.setupWithViewPager(mViewPager);
        setAdapter();
        return view;
    }

    //返回fragment的view
    //abstract View getFragmentView(ViewGroup container) ;
    public abstract void setAdapter();
}
